#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "WindowManager.h"
#include "listforms/chatlistform.h"
#include "listforms/contactform.h"
#include "subwindow/nonewindow.h"
#include "utilsform/userinfoform.h"
#include "utilsform/headmenuform.h"

#include <QListWidgetItem>
#include <QWidget>
#include <algorithm>
#include <data/Message.pb.h>
#include <data/UserInfo.pb.h>
#include <map>
#include <module/basicwindows.h>
using namespace proto;
namespace Ui {
    class MainWindow;
}

class MainWindow : public BasicWindows {
    Q_OBJECT

public:
    explicit MainWindow(QWidget* parent = nullptr);
    ~MainWindow();

public slots:
    void onAddSubWindow(QWidget* subWindow);

private slots:
    void onLogin(int code);
    void onHeadLabelClicked();
    void onSetUserInfo();

    void onSignalToggleChatListForm();

    void on_btn_menu_clicked();

    void on_btn_headMenu_clicked();

protected:
    void init();
    void initTitleBar();
    void initWindowManager();
    void initNoneWindow();
    void initList();
    void initChatListForm();
    void initContactForm();
    void initInfoForm();

    virtual void setContentMargin(int margin);

private:
    Ui::MainWindow*                     ui;
    std::map<QString, data::FriendInfo> m_firends;

    UserInfoForm* infoForm   = nullptr;
    NoneWindow*   noneWindow = nullptr;

    ChatListForm*  chatListForm  = nullptr;
    ContactForm*   contactForm   = nullptr;
    WindowManager* windowManager = nullptr;
};

#endif  // MAINWINDOW_H
